<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>专家回复界面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../res/layui/css/layui.css">
    <link rel="stylesheet" href="../../res/css/bootstrap.min.css">
    <script src="../../res/js/jquery-3.1.1.min.js" charset="utf-8"></script>
    <script src="../../res/js/Tools.js"></script>
    <script src="../../res/layui/layui.js"></script>
    <style>
        .layui-form-label{
            width: 100px;
        }
    </style>

    <script type="text/javascript">
        //全局同步
        $.ajaxSetup({
            async: false
        });

    </script>

    <script type="text/javascript">
        $(function () {
            var url = "../../User/findSession";
            $.post(url,null,function(obj){
                $("#id").val(obj.clerkId);
            });
            var schemeId = getQueryString("schemeId");
            $("#schemeId").val(schemeId);
            var sort = getQueryString("sort");
            if (sort == 20 ){
                var urls = "../../AtsSchemeController/updateAuditState?sort=30&schemeId="+$("#schemeId").val();
                $.post(urls,null);//将AtsScheme的状态调成30
                var url = "../../AtsSchemeController/atsSchemeExpertUpdateByPrimaryKeySelective?auditState=30&schemeId="+$("#schemeId").val();
                $.post(url,null);//将AtsSchemeExpert的状态调成30
                var url = "../../AtsSchemeController/updateAtsSchemeAudit?auditState=30&saId="+$("#schemeId").val();
                $.post(url,null);//将AtsSchemeExpert的状态调成30
            }

            $.ajax({
                url:"../../AtsSchemeController/selectExist",
                type:"post", // 传输类型
                data:{'schemeId' : schemeId},
                success:function(obj){
                    for(var i in obj){
                        if(obj[i].expertId == $("#id").val()){
                            if(obj[i].auditState == 30 || obj[i].auditState == 40){
                                $("#applyForExp").val(obj[i].applyForExp);
                            }
                        }
                    }
                }
            });

            $.ajax({
                url:"../../AtsSchemeController/selectExist",
                type:"post", // 传输类型
                data:{'schemeId' : schemeId},
                success:function(obj){
                    for(var i in obj){
                        if(obj[i].auditState == 40){
                            $("#results").val(obj[i].results);
                            $("#results").attr("readonly","readonly");
                            $("#testListAction").attr("class","layui-btn layui-btn-disabled");
                            $("#testListAction").attr("disabled","disabled");
                            $("#testListAction").html("已回复");
                        }
                    }

                }

            });

        });

    </script>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>专家回复界面</legend>
</fieldset>

<div><form class="layui-form" action="" id="inputForm" >

    <div class="layui-form-item">
        <label class="layui-form-label">方案名称</label>
        <div class="layui-input-block">
            <input type="text" name="auditState" id ="auditState" autocomplete="off" class="layui-input" hidden>
            <input type="text" name="saName" id ="schemeName" lay-verify="required" autocomplete="off" class="layui-input" >
            <input type="text" name="schemeId" id ="schemeId" autocomplete="off" class="layui-input" hidden>
            <input type="text" name="id" id ="id" autocomplete="off" class="layui-input" hidden>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">申请理由</label>
        <div class="layui-input-block">
            <textarea name="applyForExp" readonly="readonly" id ="applyForExp" lay-verify="required" placeholder="请输入您的意见和建议" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">申请人</label>
        <div class="layui-input-block">
            <input type="text" name="coachName" id ="coachName" lay-verify="required" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">专家意见</label>
        <div class="layui-input-block">
            <textarea name="results" id ="results" lay-verify="required" placeholder="请输入专家意见" class="layui-textarea"></textarea>
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" id="testListAction" lay-filter="demo1">立即提交</button>
        </div>
    </div>
</form></div>



<script type="text/javascript">
    /**
     * 关闭当前弹出层
     */
    function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
        parent.layui.table.reload('schemeId');
    }

</script>
<script>
    layui.use(['form', 'layedit', 'layer', 'laydate','tree','util','upload'], function(){
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , tree = layui.tree
            ,util = layui.util
            ,upload = layui.upload;

        form.render();

        //监听提交
        form.on('submit(demo1)', function(data){
            var urls = "../../AtsSchemeController/updateAuditState?sort=40&schemeId="+$("#schemeId").val();
            $.post(urls,null);//将AtsScheme的状态调成30
            var url = "../../AtsSchemeController/updateAtsSchemeAudit?auditState=40&saId="+$("#schemeId").val();
            $.post(url,null);//将AtsSchemeExpert的状态调成30
            $("#auditState").val("40");
            var url = "../../AtsSchemeController/atsSchemeExpertUpdateByPrimaryKeySelective";
            var formData = new FormData(document.getElementById("inputForm"));
            //传输路径
            $.ajax({
                url:url,
                type:"post", // 传输类型
                data:formData, // 数据
                async:false, // 全局同步
                processData:false,
                contentType:false,
                dataType:"json",
                success:function(obj){
                    // alert("操作成功");
                    //     layer.alert("操作成功");
                    layer.msg(obj.msg,{
                        icon:1,
                        time:1000,
                    },function(){
                        closeWindow();
                    });
                    return false ;


                },
                error:function(e){
                    alert("操作失败");
                    closeWindow();
                    return false ;
                }
            });

            return false ;
            // closeWindow();//关闭窗口

        });



    });

</script>

</body>
</html>